﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using ECommerce.DAL;

namespace Entity
{
    public partial class TblProduct
    {
        public static TblProduct GetTblProductByProductPath(String path)
        {
         
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@Productpath", SqlDbType.VarChar, path.Length, ParameterDirection.Input, path);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblProduct_GetTblProductByProductPath");
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblProductCollectionFromReader);
            CustomCollection<TblProduct> objCollection = ((CustomCollection<TblProduct>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }

        public static TblProduct GetTblProductByProductPath(String path, String partnerName)
        {

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@Productpath", SqlDbType.VarChar, path.Length, ParameterDirection.Input, path);            
            AddParameterToSqlCmd(sqlCmd, "@partnerName", SqlDbType.VarChar, partnerName.Length, ParameterDirection.Input, partnerName);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblProduct_GetSupplierTblProductByProductPath");
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(TblPartnerProduct.GenerateTblProductCollectionFromReaderExtended);
            CustomCollection<TblProduct> objCollection = ((CustomCollection<TblProduct>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }
    }
}